package com.dingup.paike.feign.server.message;


import com.dingup.paike.feign.client.user.UserFeignClient;
import com.dingup.paike.service.message.DingTalkMsgService;
import com.dingup.paike.service.message.WxMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by wancheng on 2018/10/27.
 */
@RestController()
@RequestMapping("/paike/feign/message")
public class PaikSendMsgFeign {

    @Autowired
    DingTalkMsgService dingTalkMsgService;
    @Autowired
    WxMsgService wxMsgService;
    @Autowired
    UserFeignClient userFeignClient;

    @RequestMapping(value = "/send_homework_finish_msg_for_teacher.do", method = RequestMethod.POST)
    public void sendHomeworkFinishMsgForTeacher(@RequestParam("userId") String userId,
                                                @RequestParam("userName") String userName,
                                                @RequestParam("homeworkId") Integer homeworkId,
                                                @RequestParam("studentName") String studentName,
                                                @RequestParam("subjectName") String subjectName) {
        dingTalkMsgService.sendMsgForHomeworkFinish(userId, userName, homeworkId, studentName, subjectName);
    }

    @RequestMapping(value = "/send_homework_msg_for_student.do", method = RequestMethod.POST)
    public void sendHomeworkMsgForStudent(@RequestParam("userId") String userId,
                                          @RequestParam("userName") String userName,
                                          @RequestParam("homeworkName") String homeworkName,
                                          @RequestParam("expiredTime") Date expiredTime) {
        String openId = userFeignClient.getWxOpenId(userId);
        wxMsgService.sendMsgForStudentFinishHomework(openId, userId, userName, homeworkName, expiredTime);
    }
}
